<!--
* @description:新增事故记录
* @fileName: NewAccidentRecord
* @author:李周蓬
* @date:2021-1-
* @后台人员:李周蓬
-->
<template>
  <div>
    <table>
      <tr>
        <td>事故标题：</td>
        <td>
          <el-input v-model="AddData.Title" placeholder="请输入内容"></el-input>
        </td>
      </tr>
      <tr>
        <td>车牌号：</td>
        <td>
          <el-select v-model="AddData.CarNumber" placeholder="请选择">
            <el-option
              v-for="item in bindData"
              :key="item.value"
              :label="item.License"
              :value="item.CarNumber"
            >
            </el-option>
          </el-select>
        </td>
      </tr>
      <tr>
        <td>事故日期：</td>
        <td>
          <el-date-picker
            v-model="AddData.AccidentTime"
            type="date"
            placeholder="选择日期"
          >
          </el-date-picker>
        </td>
      </tr>
      <tr>
        <td>保险公司赔偿：</td>
        <td>
          <el-input
            v-model="AddData.Compensate"
            placeholder="请输入内容"
          ></el-input>
        </td>
      </tr>
      <tr>
        <td>公司净损失：</td>
        <td>
          <el-input v-model="AddData.Loss" placeholder="请输入内容"></el-input>
        </td>
      </tr>
      <tr>
        <td>事故描述：</td>
        <td>
          <el-input
            type="textarea"
            v-model="AddData.AccidentDesc"
            placeholder="请输入内容"
          ></el-input>
        </td>
      </tr>
      <tr>
        <td>直接经济损失：</td>
        <td>
          <el-input
            type="textarea"
            v-model="AddData.AccidentResult"
            placeholder="请输入内容"
          ></el-input>
        </td>
      </tr>
      <tr>
        <td>备注：</td>
        <td>
          <el-input
            type="textarea"
            v-model="AddData.Remark"
            placeholder="请输入内容"
          ></el-input>
        </td>
      </tr>
       <tr>
        <td colspan="2">
          <el-button type="primary" @click="add">提交</el-button>
          <el-button @click="go">取消</el-button>
        </td>
      </tr>
    </table>
  </div>
</template>

<script>
export default {
  data() {
    return {
      AddData: {
        AccidentlNumber: "",
        Title: "",
        CarNumber: "",
        MaintainDesc: "",
        AccidentTime: "",
        Remark: "",
        AccidentDesc: "",
        AccidentResult: "",
        Compensate: "",
        Loss: "",
      },
      bindData: [],
    };
  },
  methods: {
    bind() {
      this.$axios
        .get("https://localhost:44399/api/app/maintain/bind")
        .then((res) => {
          this.bindData = res.data.PageData;
          this.bindData.unshift({ License: "请选择" });
        });
    },
    add() {
      this.$axios
        .post(
          "https://localhost:44399/api/app/accident/add-accident",
          this.AddData
        )
        .then((res) => {
          if (res.data > 0) {
            this.$message({
              type: "success",
              message: "添加成功!",
            });
            this.$router.push("/AccidentRecord");
          } else {
            this.$message({
              type: "error",
              message: "添加失败!",
            });
          }
        });
    },
    go() {
      this.$router.go(-1);
    },
  },
  created() {
    this.bind();
  },
};
</script>

<style>
</style>